Skip to content

fix(#768): stringify NaN as empty string per XForms spec#770

Open
latin-panda wants to merge 4 commits intomainfrom
fixes-coalesce-NaN
Open

fix(#768): stringify NaN as empty string per XForms spec#770
latin-panda wants to merge 4 commits intomainfrom
fixes-coalesce-NaN

Conversation

@latin-panda
Copy link
Copy Markdown
Collaborator

@latin-panda latin-panda commented Apr 7, 2026

Closes #768

I have verified this PR works in these browsers (latest versions):

  • Chrome
  • Firefox
  • Safari (macOS)
  • Safari (iOS)
  • Chrome for Android
  • Not applicable

What else has been done to verify that this works as intended?

Screen.Recording.2026-04-07.at.10.24.26.PM.mov

Why is this the best possible solution? Were any other approaches considered?

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Do we need any specific form for testing your changes? If so, please attach one.

What's changed

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: 6a77007

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@getodk/xpath Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@latin-panda latin-panda requested a review from sadiqkhoja April 7, 2026 21:07
@latin-panda
Copy link
Copy Markdown
Collaborator Author

@sadiqkhoja, do you have a chance to review this PR? It's small.

@sadiqkhoja
Copy link
Copy Markdown
Contributor

sure

@lognaturel
Copy link
Copy Markdown
Member

@sadiqkhoja please consider #768 (comment) before diving in deep!

@sadiqkhoja
Copy link
Copy Markdown
Contributor

certainly

{ seed: NaN, expected: 'CBEAFD' },
{ seed: Infinity, expected: 'CBEAFD' },
{ seed: -Infinity, expected: 'CFBEAD' },
{ seed: -Infinity, expected: 'CBEAFD' },
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old test expected 'CFBEAD' because we were incorrectly stringifying NaN as "NaN" and hashing it. The fix correctly stringifies NaN as "", which maps to seed 0 → 'CBEAFD'.

@latin-panda latin-panda changed the title fix(#768): coalesce should handle NaN fix(#768): stringify NaN as empty string per XForms spec Apr 8, 2026
@latin-panda
Copy link
Copy Markdown
Collaborator Author

@sadiqkhoja This is ready for review. I think the solution is more straightforward than before. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

descrepency in coalesce() with Collect

3 participants